#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pa;
#define val first
#define pos second
int pre[1000000],nex[1000000];
ll A[1000000];
int N,K;
priority_queue<pa,vector<pa>, greater<pa> > p;
int main()
{
	cin>>N>>K;
	for(int i = 1;i<=N;i++)
	{
		cin>>A[i];
		p.push({A[i],i});
		pre[i] = i-1;
		nex[i] = i+1;
	}
	pre[1] = -1;
	nex[N] = -1;
	while(K--)
	{
		pa now;
		do{
			now = p.top();
			p.pop();
		}while(A[now.pos]!=now.val);
		int PRE = pre[now.pos];
		int NEX = nex[now.pos];
		if(PRE!=-1)
		{
			A[PRE] = A[PRE]+now.val;
			p.push({A[PRE],PRE});
			nex[PRE]  = NEX;
		}
		if(NEX!=-1)
		{
			A[NEX]+=now.val;
			p.push({A[NEX],NEX});
			pre[NEX] = PRE;
		}
		A[now.pos] = -1;
	}
	for(int i = 1;i<=N;i++)
	{
		if(A[i]!=-1)
		cout<<A[i]<<' ';
	}
	return 0;
}
